package com.deductive.web.disposition.special;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.deductive.common.core.controller.BaseController;
import com.deductive.common.core.domain.AjaxResult;
import com.deductive.common.core.page.TableDataInfo;
import com.deductive.domain.special.SpecialStayAwaySystem;
import com.deductive.service.special.SpecialStayAwaySystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/specialStayAwaySystem")
@Api(tags = "远离体系管理")
public class SpecialStayAwaySystemController extends BaseController {

    @Resource
    private SpecialStayAwaySystemService stayAwaySystemService;

    @GetMapping("/pageQuery")
    @ApiOperation("分页查询")
    public TableDataInfo selectAll(SpecialStayAwaySystem specialStayAwaySystem) {
        startPage();
        List<SpecialStayAwaySystem> list = this.stayAwaySystemService.list(new QueryWrapper<>(specialStayAwaySystem));
        return getDataTable(list);
    }

    @GetMapping("{id}")
    @ApiOperation("根据id查询")
    public AjaxResult selectOne(@PathVariable Integer id) {
        return success(this.stayAwaySystemService.getById(id));
    }

    @PostMapping
    @ApiOperation("新增数据")
    public AjaxResult insert(@RequestBody SpecialStayAwaySystem specialStayAwaySystem) {
        return success(this.stayAwaySystemService.save(specialStayAwaySystem));
    }

    @PutMapping
    @ApiOperation("修改数据")
    public AjaxResult update(@RequestBody SpecialStayAwaySystem specialStayAwaySystem) {
        return success(this.stayAwaySystemService.updateById(specialStayAwaySystem));
    }

    @DeleteMapping
    @ApiOperation("删除数据")
    public AjaxResult delete(@RequestParam("idList") List<Integer> idList) {
        return success(this.stayAwaySystemService.removeByIds(idList));
    }

}
